from __future__ import annotations

try:
    from fastapi import FastAPI
    from .api import (
        SagRequest, compute_sag_service, SagPoint,
        CablewayRequest, cableway_service,
        WinchRequest, winch_service,
        ReevingRequest, reeving_service,
        CrossingRequest, crossing_system_service,
        BishopRequest, bishop_service,
    )
except Exception as e:
    raise RuntimeError("需要安装 fastapi 才能启用服务：pip install fastapi uvicorn")


app = FastAPI(title="GSSGCA API", version="0.1.0")


@app.post("/sag", response_model=list[SagPoint])
def sag_endpoint(req: SagRequest):
    return compute_sag_service(req)


@app.post("/cableway")
def cableway_endpoint(req: CablewayRequest):
    return cableway_service(req)


@app.post("/winch")
def winch_endpoint(req: WinchRequest):
    return winch_service(req)


@app.post("/reeving")
def reeving_endpoint(req: ReevingRequest):
    return reeving_service(req)


@app.post("/crossing")
def crossing_endpoint(req: CrossingRequest):
    return crossing_system_service(req)


@app.post("/bishop")
def bishop_endpoint(req: BishopRequest):
    return bishop_service(req)


